package com.tbvtc.agriculturalcreditchainserver2025.vo.farmerVo;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.tbvtc.agriculturalcreditchainserver2025.Json.TimesTampSerialized;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigInteger;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class FoodReportVo  implements Serializable {

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private LocalDateTime timestamp;
    private String reportType;
    private String growthPhotos;              // 生长阶段照片（IPFS哈希值）
    private String ertilizationRecords;     // 施肥记录（IPFS哈希值）
    private String pesticideRecords;      // 打药记录（IPFS哈希值）
    private String inspectionReport;        // 检测报告（IPFS哈希值）
    private String temperaturo;
    private String humidity;
    private String lightHours;




    @JsonCreator
    public FoodReportVo(List<Object> array) {

        this.reportType =array.get(1).toString();
        this.growthPhotos = array.get(2).toString();
        this.ertilizationRecords = array.get(4).toString();
        this.pesticideRecords = array.get(5).toString();
        this.inspectionReport = array.get(6).toString();
        this.temperaturo = array.get(3).toString();
        this.humidity = array.get(7).toString();
        this.lightHours = array.get(8).toString();
        this.timestamp = LocalDateTime.ofInstant(
                Instant.ofEpochMilli(((Number) array.get(0)).longValue()),
                ZoneId.of("Asia/Shanghai")
        );

    }
}
